import java.util.LinkedList;


public class SearchStrategy {
	
	String typeOfSearch;
	
	public SearchStrategy(String typeOfSearch) {
		super();
		this.typeOfSearch = typeOfSearch;
	}

	public String getTypeOfSearch() {
		return typeOfSearch;
	}

	public void setTypeOfSearch(String typeOfSearch) {
		this.typeOfSearch = typeOfSearch;
	}

	public LinkedList<Node> search(LinkedList<Node> visitedNodes ,Node exploredNode)
	{
		
		  if (getTypeOfSearch().equals("BF"))
		  {
			  visitedNodes=BFSearch(visitedNodes ,exploredNode); 
		  } 
		  if(getTypeOfSearch().equals("DF"))
		  {
			  visitedNodes= DFSearch(visitedNodes ,exploredNode);
		  }
		  if(getTypeOfSearch().equals("ID"))
		  {
			  visitedNodes= DFIterativeSearch(visitedNodes ,exploredNode);
		  }
		  if(getTypeOfSearch().equals("GR1"))
		  {
			  visitedNodes= GR1Search(visitedNodes ,exploredNode); 
		  }
		  if(getTypeOfSearch().equals("GR2")) 
		  {
			  visitedNodes=GR2Search(visitedNodes ,exploredNode); 
		  }
		  if(getTypeOfSearch().equals("AS1"))
		  {
			  visitedNodes=AS1Search(visitedNodes ,exploredNode);
		  }
		  if(getTypeOfSearch().equals("AS2"))
		  {
			  visitedNodes=AS2Search(visitedNodes ,exploredNode);
		  }
		 return visitedNodes;
	}
	
	
	public LinkedList<Node> BFSearch(LinkedList<Node> visitedNodes ,Node exploredNode)
	{
		LinkedList<Node> nodeChildren =exploredNode.insertInList(exploredNode);

		while(!nodeChildren.isEmpty())
		{
			visitedNodes.addLast(nodeChildren.pop());
		}
		return visitedNodes;
	}
	public LinkedList<Node> DFSearch(LinkedList<Node> visitedNodes ,Node exploredNode)
	{
		LinkedList<Node> nodeChildren =exploredNode.insertInList(exploredNode);
		
		while(!nodeChildren.isEmpty())
		{
			visitedNodes.addFirst(nodeChildren.pop());
		}
		return visitedNodes;
	}
	public LinkedList<Node> DFIterativeSearch(LinkedList<Node> visitedNodes ,Node exploredNode)
	{
		return visitedNodes;
	}
	public LinkedList<Node> GR1Search(LinkedList<Node> visitedNodes ,Node exploredNode)
	{
		return visitedNodes;
	}
	public LinkedList<Node> GR2Search(LinkedList<Node> visitedNodes ,Node exploredNode)
	{
		return visitedNodes;
	}
	public LinkedList<Node> AS1Search(LinkedList<Node> visitedNodes ,Node exploredNode)
	{
		return visitedNodes;
	}
	public LinkedList<Node> AS2Search(LinkedList<Node> visitedNodes ,Node exploredNode)
	{
		return visitedNodes;
	}
}
